package com.maccman.aireo.command
{
	/* add to controller
	addCommand( UpdateAssetEvent.EVENT_UPDATE_ASSET, UpdateAssetCommand );
	*/
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.adobe.cairngorm.commands.ICommand;

	import com.maccman.aireo.model.AireoModelLocator;
	import com.maccman.aireo.control.UpdateAssetEvent;

	import mx.controls.Alert;
	import mx.rpc.IResponder;
	import mx.rpc.events.FaultEvent;
	
	import com.maccman.activeresource.ActiveResource;
	import com.maccman.activeresource.IndexedCollection;
	import com.maccman.activeresource.models.Asset;
	
	import com.maccman.aireo.vo.AssetVO;

	public class UpdateAssetCommand implements ICommand, IResponder
	{
		public function execute(event:CairngormEvent):void
		{
		    var delegate : Asset = new Asset( this );
		    var updateAssetEvent:UpdateAssetEvent = UpdateAssetEvent( event );
		    delegate.save(updateAssetEvent.asset);
		}
		
		public function result(data:Object):void
		{
		   AssetVO.find(data.id).update(data as Object)
		}
		
		public function fault(info:Object):void
		{
			var event:FaultEvent = info as FaultEvent;
		}
		
	}
}